.PHONY: build run test clean

# 构建
build:
	go build -o bin/mqtt-broker cmd/broker/main.go
	go build -o bin/test-client cmd/test-client/main.go

# 运行broker
run:
	go run cmd/broker/main.go

# 运行测试
test:
	go test -v ./...

# 清理
clean:
	rm -rf bin/

# 安装依赖
deps:
	go mod tidy
	go mod download

# 格式化代码
fmt:
	go fmt ./...

# 静态检查
lint:
	golangci-lint run

# 发布消息测试
test-pub:
	go run cmd/test-client/main.go -mode=pub -topic=test/hello -msg="Hello World"

# 订阅消息测试
test-sub:
	go run cmd/test-client/main.go -mode=sub -topic=test/hello

# Docker构建
docker-build:
	docker build -t mqtt-broker .

# Docker运行
docker-run:
	docker run -p 1883:1883 mqtt-broker
